package com.maijinjie.common.upload;

import java.util.List;
import java.util.Map;

import com.maijinjie.common.upload.bean.FileVo;

public class SingleFileUploadHandler implements FileUploadHandler {

	@Override
	public String returnFileUploadPlace() {		
		return "files/";
	}

	@Override
	public void handleUploadFile(Map<String, String> parameter,
			Map<String, Object> returnMessage, List<FileVo> list)
			throws Exception {
		FileVo vo = list.get(0);
		returnMessage.put("path",vo.getUrl());
		returnMessage.put("name", vo.getRealName());
		returnMessage.put("endfix", getEndfix(vo.getRealName()));
	}

	private Object getEndfix(String realName) {
		String[] arr = realName.split("[.]");
		return arr[arr.length-1];
	}

}
